const app = getApp();
const Controller = require("../../controllers/controllers").controller

Component({
  properties: {
    type:{
      type:Number,
      value:1, //1 课程  、 2 产品 、3 潮色 、 4 沙龙 、 5 抽奖
      observer:function(newVal,oldVal,change){
        this.appinfo()
      }
    },
    title:{
      type:String,
      value:""
    },
    img:{
      type:String,
      value:''
    },
    path:{
      type:String,
      value:''
    },
    id:{
      type:Number,
      value:""
    },
    show:{
      type:Boolean,
      value:false
    },
  },
  data: {
   navHeight:'',
  },
  ready(options) {


  },
  methods: {
    appinfo(){
      var keytitle="key-share-video-title";
      var keyimg="key-share-video-imgUrl";
      if(this.data.type==1){
        keytitle="key-share-video-title";
        keyimg="key-share-video-imgUrl";
      }else if(this.data.type==2){
        keytitle="key-share-product-title";
        keyimg="key-share-product-imgUrl";
      }else if(this.data.type==5){
        keytitle="key-share-prize-title";
        keyimg="key-share-prize-imgUrl";
      }
      Controller.appinfo({key:keytitle}).then(res=>{
        if(res.data.baseData){
          this.setData({
            title:res.data.baseData.content
          })
          this.triggerEvent('sharetitle', res.data.baseData.content)
        }
      })
      Controller.appinfo({key:keyimg}).then(res=>{
        if(res.data.baseData){
          this.setData({
            img:res.data.baseData.content
          })
          this.triggerEvent('shareimg', res.data.baseData.content)
        }
      })
    },
    saveImgBtn() {
      wx.showLoading({
        title: '保存中',
        mask: true,
      })
      var that=this;
      setTimeout(()=>{
        app.saveImg(that.data.img)
      },800)
      
    },
    cancel(){
      this.setData({
        show:false
      })
    },
    
  },

})